<template>
  <div class="VoucherCenter">
    <div class="head">
      <div class="ift-back" @click="returns"></div>
      <h1>充值中心</h1>
      <h2 @click="UserAgreement">用户协议</h2>
    </div>
    <div class="balancediv">
      <div class="balance">
        <div>余额</div>
        <div>
          <span>{{ Diamonds }}</span>
          钻石 (含充值钻石
          <span>{{ Diamonds }}</span
          >)
        </div>
      </div>
    </div>
    <div class="Recharge">
      <p>充值金额</p>
      <ul>
        <li
          v-for="(item, index) in amount"
          :key="index"
          @click="cz(item.Price)"
        >
          <h1>￥{{ item.Price }}.0</h1>
          <h2>{{ item.quantity }}钻石</h2>
          <h3>(送{{ item.quantity }}金币)</h3>
        </li>
      </ul>
      <p class="Tips">
        温馨提示:<br />
        购买后，账户余额若长时间无变化，请及时联系我们为您解决，客服QQ:110
      </p>
    </div>
    <div class="amount-of-money" v-show="flag">
      <div class="mode">
        <div class="queren">
          <div></div>
          <h1>确认支付方式</h1>
          <div @click="flag = false">取消</div>
        </div>
        <ul>
          <li :class="num == 0 ? 'con' : ''" @click="num = 0">
            <p class="wx"></p>
            <div>微信</div>
            <i class="ift-check"></i>
          </li>
          <li :class="num == 1 ? 'con' : ''" @click="num = 1">
            <p class="zfb"></p>
            <div>支付宝</div>
            <i class="ift-check"></i>
          </li>
        </ul>
        <div class="price">
          <h1>￥{{ jg }}.0</h1>
          <h2>钻石X{{ jg * 100 }}</h2>
        </div>
        <div class="payment" @click="payment(jg * 100)"><p>立即支付</p></div>
      </div>
    </div>
  </div>
</template>
<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      Diamonds: 0,
      amount: [
        {
          Price: 6,
          quantity: 600,
        },
        {
          Price: 18,
          quantity: 1800,
        },
        {
          Price: 50,
          quantity: 5000,
        },
        {
          Price: 98,
          quantity: 9800,
        },
        {
          Price: 168,
          quantity: 16800,
        },
        {
          Price: 298,
          quantity: 29800,
        },
      ],
      num: 0,
      image: [],
      flag: false,
      jg: 0,
    };
  },
  methods: {
    payment(jg) {
      this.cz();
      this.$store.commit("jsjg", jg);
      this.Diamonds = this.$store.state.jg;
      Toast("感谢主人的支持~喵");
    },
    cz(Price) {
      this.flag = !this.flag;
      this.jg = Price;
    },
    returns() {
      this.$router.go("-1");
    },
    UserAgreement() {
      this.$router.push("/my/UserAgreement");
    },
  },
  created() {
    this.Diamonds = this.$store.state.jg;
  },
};
</script>
<style lang="less">
.VoucherCenter {
  .head {
    padding: 0 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .cancel {
      font-size: 14px;
      color: black;
    }
    div {
      width: 60px;
      font-size: 20px;
      color: #fc6976;
    }
    h1 {
      flex: 1;
      font-size: 18px;
      font-weight: 500;
      text-align: center;
    }
    h2 {
      color: #fc6976;
      font-size: 12px;
      font-weight: 400;
      border: 1px solid #fc6976;
      border-radius: 10px;
      padding: 0 1%;
    }
  }
  .balancediv {
    border-bottom: 1px solid #e5e5e5;
    .balance {
      width: 90%;
      margin: 4% auto;
      display: flex;
      justify-content: space-between;
      div {
        &:nth-child(1) {
          width: 50%;
        }
        &:nth-child(2) {
          flex: 1;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        span {
          margin: 0 1%;
          color: #fc6976;
        }
      }
    }
  }
  .Recharge {
    width: 90%;
    margin: 0 auto;
    p {
      font-size: 14px;
      color: #999;
    }
    ul {
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      li {
        width: 30%;
        text-align: center;
        border: 1px solid #ccc;
        padding: 5% 0;
        margin: 2% 0;
        border-radius: 8px;
        box-shadow: 4px 4px 4px #dedede;
        h1 {
          font-size: 18px;
          color: #fc6976;
          font-weight: 200;
          margin: 0;
        }
        h2 {
          font-size: 16px;
          font-weight: 500;
          margin: 0;
        }
        h3 {
          font-size: 13px;
          color: #999;
          font-weight: 200;
          margin: 0;
        }
      }
    }
    .Tips {
      font-size: 12px;
      opacity: 0.8;
    }
  }
  .amount-of-money {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    position: fixed;
    top: 0;
    .mode {
      width: 100%;
      height: 40%;
      background-color: white;
      position: fixed;
      bottom: 0;
      .queren {
        display: flex;
        align-items: center;
        text-align: center;
        div {
          width: 20%;
          font-size: 12px;
          color: #999;
        }
        h1 {
          flex: 1;
          font-size: 14px;
        }
      }
      ul {
        li {
          width: 90%;
          padding: 0 5%;
          display: flex;
          align-items: center;
          justify-content: space-between;
          border-bottom: 1px solid #dedede;
          &:nth-child(1) {
            border-top: 1px solid #dedede;
          }
          .wx,
          .zfb,
          i {
            background-size: 100%;
            width: 30px;
            height: 30px;
            line-height: 30px;
            margin: 2% 5%;
            text-align: center;
          }
          .wx {
            background-image: url(https://m.kanman.com/static/images/bank/wx.png);
          }
          .zfb {
            background-image: url(https://m.kanman.com/static/images/bank/zfb.png);
          }
          div {
            flex: 1;
          }
          i {
            text-align: right;
            font-size: 20px;
            color: #999;
          }
        }
        .con {
          background-color: #ddd;
          div {
            color: white;
          }
          i {
            color: #7ed321;
          }
        }
      }
      .price {
        text-align: center;
        h1 {
          font-size: 20px;
          color: #fc6976;
          font-weight: 400;
          margin-bottom: 0;
        }
        h2 {
          font-size: 14px;
          color: #999;
          margin: 0;
          font-weight: 400;
        }
      }
      .payment {
        width: 90%;
        margin: 5% auto;
        padding: 3% 0;
        border-radius: 40px;
        background-color: #fc6976;
        color: white;
        text-align: center;
        p {
          margin: 0;
        }
      }
    }
  }
}
</style>